<?php

namespace app\push\model;
use think\Model;
use think\Hook;

class ChatRooms extends Model {

        public function getlist($where=[],$whereOr=[],$order=''){
            $list = $this->order($order)->where($where)->whereOr($whereOr)->with(['user','other','details'=>function($query){
                $query->order('id');
            }])->select();
            return $list;
        }

        public function user(){
            return $this->hasOne('User','id','user_id');
        }

        public function other()
        {
            return $this->hasOne('User','id','other_id');
        }

        public function details()
        {
            return $this->hasOne('ChatDetails','room_id','id');
        }

}